package com.aat.dxfy.autoCode;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

/**
 * 
 * @author wuxin
 * @info 读取xlsm,xlss创建bean dao service controller
 *
 */
public class BaseUIMysqlCode {
	private String baseDir;// xlsm所在基本目录
	private String xlsmName;// 文件名
	private String packagePath;// com.公司名.项目名

	private String moduleName;// 模块名
	private String packageName;// com.公司名.项目名
	private String beanName;
	private String tableName;
	private List<String> fileds = new ArrayList<String>();
	private List<String> types = new ArrayList<String>();
	private List<String> texts = new ArrayList<String>();
	private String javaMakeCodeDir="javaMakeCodeDir";

	public BaseUIMysqlCode(String baseDir, String xlsmName, String packagePath) {
		this.baseDir = baseDir;
		this.xlsmName = xlsmName;
		this.packagePath = packagePath;
		packageName = packagePath.replaceAll("/", ".");// com.公司名.项目名
	}

	// 0,读取xlsm 形式
	public void getBaseInfo4Xlsm() throws IOException, InterruptedException {
		XSSFWorkbook xssfWorkbook = new XSSFWorkbook(baseDir + xlsmName);
		// 读取目录
		XSSFSheet xssfSheetML = xssfWorkbook.getSheetAt(0);
		for (int i = 1; i <= xssfSheetML.getLastRowNum(); i++) {
			XSSFRow rowML = xssfSheetML.getRow(i);
			if (rowML == null) {
				continue;
			}

			String tbName = null;
			String isOk = null;
			try {
				tbName = getXlssVal(rowML.getCell(2));
				isOk = getXlssVal(rowML.getCell(4));
			} catch (NullPointerException q) {
				continue;
			}

			if (isNotEmpty(tbName) && isNotEmpty(isOk)) {
				if ("yes".equals(isOk)) {
					XSSFSheet xssfSheet = xssfWorkbook.getSheet(tbName);
					//
					if (null != xssfSheet) {
						// 装数
						tableName = xssfSheet.getSheetName();
						if(tableName.startsWith("t_")) {
							tableName = tableName.replace("t_", "");
						}
						String[] ss = tableName.split("_");
						moduleName = ss[0];
						String str = ss[1];
						beanName = str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
						fileds.clear();
						types.clear();
						texts.clear();
						//
						for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
							XSSFRow xssfRow = xssfSheet.getRow(rowNum);
							String text = getXlssVal(xssfRow.getCell(1));
							String filed = getXlssVal(xssfRow.getCell(2));
							String type = getXlssVal(xssfRow.getCell(3));
							fileds.add(filed);
							types.add(getFiledType(type));
							texts.add(text);
						}
						// 开始
						createJavaBean();

						createDao();

						createDaoXml();

						createService();

						createServiceImpl();

						createWebController();

						//toFormDiv();

						makeListJSP();
						
						makeEditJSP();
						// 结束
					}
					// 改变已经生成过的代码
					rowML.getCell(4).setCellValue("not");
				}
			}
		}
		xssfWorkbook.close();
		//

	}

	// 2,根据读取的信息，创建实体类,{entity}.java
	public void createJavaBean() {
		// 创建包
		String javaFilePath = baseDir + javaMakeCodeDir + File.separator + packagePath + File.separator + moduleName
				+ File.separator + "bean";
		createPackage(javaFilePath);
		// 代码
		StringBuffer sb = new StringBuffer();
		sb.append("package " + packageName + "." + moduleName + ".bean;\n\n");// 包
		sb.append("import java.io.Serializable;\n");
		sb.append("import java.util.*;\n\n");

		sb.append("public class " + beanName + "  implements Serializable{\n");// 类

		sb.append("    private static final long serialVersionUID = 1L;\n");
		for (int i = 0; i < fileds.size(); i++) {
			sb.append("    private " + types.get(i) + " " + fileds.get(i) + ";\n");
		}

		// set get
		sb.append("\n");
		for (int i = 0; i < fileds.size(); i++) {
			String fn1 = fileds.get(i);
			String fn2 = fn1.substring(0, 1).toUpperCase() + fn1.substring(1, fn1.length());
			sb.append("    public " + types.get(i) + " get" + fn2 + "() {\n");
			sb.append("        return " + fn1 + ";\n");
			sb.append("    }\n\n");

			sb.append("    public void set" + fn2 + "(" + types.get(i) + " " + fn1 + ") {\n");
			sb.append("        this." + fn1 + " = " + fn1 + ";\n");
			sb.append("    }\n\n");
		}

		// hashcode
		sb.append("    public int hashCode() {\n");
		sb.append("        final int prime = 31;\n");
		sb.append("        int result = 1;\n");
		sb.append("        result = prime * result + ((id == null) ? 0 : id.hashCode());\n");
		sb.append("        return result;\n");
		sb.append("    }\n\n");

		// equals
		sb.append("    public boolean equals(Object obj) {\n");
		sb.append("        if (this == obj)\n");
		sb.append("            return true;\n");
		sb.append("        if (obj == null)\n");
		sb.append("            return false;\n");
		sb.append("        if (getClass() != obj.getClass())\n");
		sb.append("            return false;\n");
		sb.append("        " + beanName + " other = (" + beanName + ") obj;\n");
		sb.append("        if (id == null) {\n");
		sb.append("            if (other.id != null)\n");
		sb.append("                return false;\n");
		sb.append("        } else if (!id.equals(other.id))\n");
		sb.append("            return false;\n");
		sb.append("        return true;\n");
		sb.append("    }\n\n");

		// tostr
		sb.append("    public String toString() {\n");
		sb.append("       return \"" + beanName + " [id=\"+ id +\"]\";\n");
		sb.append("    }\n\n");

		// ok
		sb.append("}\n");
		writeS(new String(sb), "utf-8", javaFilePath + File.separator + beanName + ".java");
	}

	// 3-1,根据读取的信息，创建实体Dao,{entity}Dao.java\{entity}Dao.xml
	public void createDao() {
		// 创建包
		String javaFilePath = baseDir + javaMakeCodeDir + File.separator + packagePath + File.separator + moduleName
				+ File.separator + "dao";
		createPackage(javaFilePath);
		// 代码
		StringBuffer sb = new StringBuffer();
		sb.append("package " + packageName + "." + moduleName + ".dao;\n\n");// 包
		sb.append("import java.util.*;\n");
		sb.append("import org.springframework.stereotype.Repository;\n");
		sb.append("import " + packageName + "." + moduleName + ".bean." + beanName + ";\n\n");// 导包

		sb.append("@Repository\n");
		sb.append("public interface " + beanName + "Dao{\n\n");// 类

		sb.append("    int addBean(" + beanName + " bean);\n\n");
		sb.append("    int updateBean(" + beanName + " bean);\n\n");
		sb.append("    int deleteBean(String id);\n\n");
		sb.append("    " + beanName + " queryBean(String id);\n\n");
		sb.append("    List<" + beanName + "> queryAll(Map<String, Object> map);\n\n");
		sb.append("    long queryCount(Map<String, Object> map);\n\n");

		sb.append("}\n");
		writeS(new String(sb), "utf-8", javaFilePath + File.separator + beanName + "Dao.java");
	}

	// 3-2,根据读取的信息，创建实体Dao,{entity}Dao.java\{entity}Dao.xml
	public void createDaoXml() {
		// 创建包
		String javaFilePath = baseDir + javaMakeCodeDir + File.separator + packagePath + File.separator + ""
				+ moduleName + File.separator + "dao";
		createPackage(javaFilePath);
		// 代码
		StringBuffer sb = new StringBuffer();
		// head
		sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
		sb.append(
				"<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\"\n\"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">\n");
		sb.append("<mapper namespace=\"" + packageName + "." + moduleName + ".dao." + beanName + "Dao\">\n\n");

		// 表
		sb.append("    <!-- 表 -->\n");
		sb.append("    <sql id=\"Table_Name\">\n");
		sb.append("        " + tableName + "\n");
		sb.append("    </sql>\n\n");

		// 字段
		sb.append("    <!-- 字段 -->\n");
		sb.append("    <sql id=\"Base_Column_List\">\n");
		String column = "        ";
		for (int i = 0; i < fileds.size(); i++) {
			if (i != 0 && i % 5 == 0) {
				column += "\n        ";
			}
			String f = fileds.get(i);
			if (isNotEmpty(f)) {
				column += f + ",";
			}
		}
		column = column.substring(0, column.length() - 1);
		sb.append(column + "\n");
		sb.append("    </sql>\n\n");
		//

		// add
		sb.append("    <!-- 新增 -->\n");
		sb.append("    <insert id=\"addBean\" parameterType=\"" + beanName + "\">\n");
		sb.append("        INSERT INTO\n");
		sb.append("        <include refid=\"Table_Name\" />\n");
		sb.append("        (\n");
		sb.append("        <include refid=\"Base_Column_List\" />\n");
		sb.append("        ) VALUES\n");
		sb.append("        (\n");
		String columnkh = "        ";
		for (int i = 0; i < fileds.size(); i++) {
			if (i != 0 && i % 5 == 0) {
				columnkh += "\n        ";
			}
			String f = fileds.get(i);
			if (isNotEmpty(f)) {
				columnkh += "#{" + f + "},";
			}
		}
		columnkh = columnkh.substring(0, columnkh.length() - 1);
		sb.append(columnkh + "\n");
		sb.append("        )\n");
		sb.append("    </insert>\n\n");
		//

		// upt
		sb.append("    <!-- 修改 -->\n");
		sb.append("    <update id=\"updateBean\" parameterType=\"" + beanName + "\">\n");
		sb.append("        UPDATE\n");
		sb.append("        <include refid=\"Table_Name\" />\n");
		sb.append("        <set>\n");
		sb.append("            <include refid=\"updateSQL\"/>\n");
		sb.append("        </set>\n");
		sb.append("        WHERE id = #{id}\n");
		sb.append("    </update>\n\n");

		// del
		sb.append("    <!-- 删除 -->\n");
		sb.append("    <delete id=\"deleteBean\" parameterType=\"java.lang.String\">\n");
		sb.append("        DELETE FROM\n");
		sb.append("        <include refid=\"Table_Name\" />\n");
		sb.append("        WHERE id = #{id}\n");
		sb.append("    </delete>\n\n");

		// queryBean
		sb.append("    <!-- 查询单个 -->\n");
		sb.append("    <select id=\"queryBean\" parameterType=\"java.lang.String\" resultType=\"" + beanName + "\">\n");
		sb.append("        SELECT <include refid=\"Base_Column_List\" /> FROM \n");
		sb.append("        <include refid=\"Table_Name\" />\n");
		sb.append("        WHERE id = #{id}\n");
		sb.append("    </select>\n\n");

		// queryAll
		sb.append("    <!-- 查询所有 -->\n");
		sb.append("    <select id=\"queryAll\" parameterType=\"java.util.Map\" resultType=\"" + beanName + "\">\n");
		sb.append("        SELECT <include refid=\"Base_Column_List\" /> FROM \n");
		sb.append("        <include refid=\"Table_Name\" />\n");
		sb.append("        <include refid=\"condition\" />\n");
		sb.append("        <include refid=\"splitPages\" />\n");
		sb.append("    </select>\n\n");

		// queryCount
		sb.append("    <!-- 查询总数 -->\n");
		sb.append("    <select id=\"queryCount\" parameterType=\"java.util.Map\" resultType=\"java.lang.Long\">\n");
		sb.append("        SELECT COUNT(*) FROM \n");
		sb.append("        <include refid=\"Table_Name\" />\n");
		sb.append("        <include refid=\"condition\" />\n");
		sb.append("    </select>\n\n");

		// uptsql
		sb.append("    <sql id=\"updateSQL\">\n");
		String uptsql = "";
		for (int i = 0; i < fileds.size(); i++) {
			String f = fileds.get(i);
			if ("id".equals(f)) {
				continue;
			}
			if (isNotEmpty(f)) {
				uptsql += "        <if test=\"" + f + " != null\">" + f + " = #{" + f + "},</if>\n";
			}
		}
		sb.append(uptsql + "\n");
		sb.append("    </sql>\n\n");

		// con
		sb.append("    <sql id=\"condition\">\n");
		sb.append("        <where>\n");
		String consql = "";
		for (int i = 0; i < fileds.size(); i++) {
			String f = fileds.get(i);
			if ("id".equals(f)) {
				continue;
			}
			if (isNotEmpty(f)) {
				consql += "            <if test=\"" + f + " != null\">AND " + f + " = #{" + f + "} </if>\n";
			}
		}
		sb.append(consql + "\n");
		sb.append("            <if test=\"skey != null\">AND id LIKE concat('%',#{skey},'%')</if>\n");

		sb.append("      </where>\n");
		sb.append("    </sql>\n\n");

		// split
		sb.append("    <sql id=\"splitPages\">\n");
		sb.append("        <if test=\"sortFiled != null\">\n");
		sb.append("            ORDER BY ${sortFiled}\n");
		sb.append("        </if>\n");
		sb.append("        <if test=\"sortFiled != null and direction != null \">\n");
		sb.append("            ${direction}\n");
		sb.append("        </if>\n");
		sb.append("        <if test=\"start!=null\">\n");
		sb.append("            LIMIT #{start}\n");
		sb.append("        </if>\n");
		sb.append("        <if test=\"start!=null and perpage!=null\">\n");
		sb.append("            ,#{perpage}\n");
		sb.append("        </if>\n");
		sb.append("    </sql>\n\n");
		sb.append("</mapper>\n");
		//
		writeS(new String(sb), "utf-8", javaFilePath + File.separator + beanName + "Dao.xml");
	}

	// 4-1,根据读取的信息，创建实体service,{entity}Service.java\{entity}ServiceImpl.java
	public void createService() {
		// 创建包
		String javaFilePath = baseDir + File.separator + javaMakeCodeDir + File.separator + packagePath + ""
				+ File.separator + moduleName + File.separator + "service";
		createPackage(javaFilePath);
		// 代码
		StringBuffer sb = new StringBuffer();
		sb.append("package " + packageName + "." + moduleName + ".service;\n\n");
		sb.append("import java.util.*;\n");
		sb.append("import " + packageName + "." + moduleName + ".bean." + beanName + ";\n\n");

		sb.append("public interface " + beanName + "Service{\n\n");

		sb.append("    int addBean(" + beanName + " bean);\n\n");
		sb.append("    int updateBean(" + beanName + " bean);\n\n");
		sb.append("    int deleteBean(String id);\n\n");
		sb.append("    " + beanName + " queryBean(String id);\n\n");
		sb.append("    List<" + beanName + "> queryAll(Map<String, Object> map);\n\n");
		sb.append("    long queryCount(Map<String, Object> map);\n\n");

		sb.append("}\n");
		writeS(new String(sb), "utf-8", javaFilePath + File.separator + beanName + "Service.java");
	}

	// 4-2,根据读取的信息，创建实体service,{entity}Service.java\{entity}ServiceImpl.java
	public void createServiceImpl() {
		// 创建包
		String javaFilePath = baseDir + File.separator + javaMakeCodeDir + File.separator + packagePath + ""
				+ File.separator + moduleName + File.separator + "service" + File.separator + "impl";
		createPackage(javaFilePath);
		// 代码
		StringBuffer sb = new StringBuffer();
		sb.append("package " + packageName + "." + moduleName + ".service.impl;\n\n");
		sb.append("import java.util.*;\n\n");

		sb.append("import org.springframework.beans.factory.annotation.Autowired;\n");
		sb.append("import org.springframework.stereotype.Service;\n\n");

		sb.append("import " + packageName + "." + moduleName + ".bean." + beanName + ";\n");
		sb.append("import " + packageName + "." + moduleName + ".dao." + beanName + "Dao;\n");
		sb.append("import " + packageName + "." + moduleName + ".service." + beanName + "Service;\n\n");

		sb.append("@Service\n");
		sb.append("public class " + beanName + "ServiceImpl  implements " + beanName + "Service {\n\n");

		String dao = beanName.toLowerCase() + "Dao";
		sb.append("    @Autowired\n");
		sb.append("    private " + beanName + "Dao " + dao + ";\n\n");

		sb.append("    public int addBean(" + beanName + " bean){\n");
		sb.append("        return " + dao + ".addBean(bean);\n");
		sb.append("    }\n\n");

		sb.append("    public int updateBean(" + beanName + " bean){\n");
		sb.append("        return " + dao + ".updateBean(bean);\n");
		sb.append("    }\n\n");

		sb.append("    public int deleteBean(String id){\n");
		sb.append("        return " + dao + ".deleteBean(id);\n");
		sb.append("    }\n\n");

		sb.append("    public " + beanName + " queryBean(String id){\n");
		sb.append("        return " + dao + ".queryBean(id);\n");
		sb.append("    }\n\n");

		sb.append("    public List<" + beanName + "> queryAll(Map<String, Object> map){\n");
		sb.append("        return " + dao + ".queryAll(map);\n");
		sb.append("    }\n\n");

		sb.append("    public long queryCount(Map<String, Object> map){\n");
		sb.append("        return " + dao + ".queryCount(map);\n");
		sb.append("    }\n\n");

		sb.append("}\n");
		writeS(new String(sb), "utf-8", javaFilePath + File.separator + beanName + "ServiceImpl.java");
	}

	// 5,根据读取的信息，创建实体controller
	public void createWebController() {
		// 创建包
		String javaFilePath = baseDir + javaMakeCodeDir + File.separator + packagePath + ""
				+ File.separator + moduleName + File.separator + "web" + File.separator + "controller";
		createPackage(javaFilePath);
		// 代码
		StringBuffer sb = new StringBuffer();
		sb.append("package " + packageName + "." + moduleName + ".web.controller;\n\n");

		sb.append("import java.util.*;\n\n");

		sb.append("import org.springframework.web.bind.annotation.*;\n");
		sb.append("import org.springframework.stereotype.Controller;\n");
		sb.append("import org.springframework.beans.factory.annotation.Autowired;\n");
		sb.append("import org.springframework.ui.Model;\n\n");

		sb.append("import com.aat.dizena.utils.Atools;\n");
		sb.append("import com.aat.dizena.base.web.controller.BaseController;\n\n");

		sb.append("import " + packageName + "." + moduleName + ".bean." + beanName + ";\n");
		sb.append("import " + packageName + "." + moduleName + ".service." + beanName + "Service;\n\n");

		sb.append("@Controller\n@RequestMapping(\"master/" + beanName.toLowerCase() + "\")\n");
		sb.append("public class Master" + beanName + "Controller  extends BaseController{\n\n");
		// base str
		sb.append("    @Autowired\n");
		sb.append("    private " + beanName + "Service " + beanName.toLowerCase() + "Service;\n\n");

		sb.append("    private String list = \"/master/" + beanName.toLowerCase() + "/list\";\n");
		sb.append("    private String edit = \"/master/" + beanName.toLowerCase() + "/edit\";\n");
		sb.append("    private String reList = \"redirect:\" + list;\n");
		sb.append("    private String addAction = \"master/" + beanName.toLowerCase() + "/add\";\n");
		sb.append("    private String uptAction = \"master/" + beanName.toLowerCase() + "/upt\";\n");
		sb.append("    private String delAction = \"master/" + beanName.toLowerCase() + "/del\";\n");

		sb.append("    private String StringKey = \" \";\n");
		sb.append("    private String addTitle = \"增加\"+StringKey;\n");
		sb.append("    private String uptTitle = \"修改\"+StringKey;\n");
		sb.append("    private String listHead = StringKey+\"管理\";\n\n");

		// list
		sb.append("    // list get\n");
		sb.append("    @RequestMapping(value = \"list\", method = RequestMethod.GET)\n");
		sb.append("    public String list(Model m) {\n");
		sb.append("        m.addAttribute(\"addAction\", addAction);\n");
		sb.append("        m.addAttribute(\"uptAction\", uptAction);\n");
		sb.append("        m.addAttribute(\"delAction\", delAction);\n");
		sb.append("        m.addAttribute(\"listHead\", listHead);\n");
		sb.append("        m.addAttribute(\"list\", list);\n");
		sb.append("        return list;\n");
		sb.append("    }\n\n");

		sb.append("    // list post\n");
		sb.append("    @RequestMapping(value = \"list\", method = RequestMethod.POST)\n");
		sb.append("    @ResponseBody\n");

		sb.append(
				"    public Map<String, Object> list(@RequestParam(value = \"s\", required = false, defaultValue = \"1\") int start,\n");
		sb.append("            @RequestParam(value = \"p\", required = false, defaultValue = \"10\") int perPage,\n");
		sb.append(
				"            @RequestParam(value = \"f\", required = false, defaultValue = \"ts\") String sortFiled,\n");
		sb.append(
				"            @RequestParam(value = \"dir\", required = false, defaultValue = \"DESC\") String direction,\n\n");
		sb.append("        @RequestParam(value = \"u\", required = false) String skey) {\n");

		sb.append("        Map<String, Object> params = new HashMap<String, Object>();\n");
		sb.append("        params.put(\"sortFiled\", sortFiled);\n");
		sb.append("        params.put(\"direction\", direction);\n");
		sb.append("        params.put(\"start\", (start - 1) * perPage);\n");
		sb.append("        params.put(\"perpage\", perPage);\n");
		sb.append("        // 其他参数\n");
		sb.append("        if (isNotEmpty(skey)) {\n");
		sb.append("            params.put(\"skey\", skey);\n");
		sb.append("        }\n\n");

		sb.append("        //  返回参数\n");
		sb.append("        List<" + beanName + "> lists = " + beanName.toLowerCase() + "Service.queryAll(params);\n");
		sb.append("        Long count = " + beanName.toLowerCase() + "Service.queryCount(params);\n");
		sb.append("        Long tmp = count / perPage;\n");
		sb.append("        Long pages = count % perPage == 0 ? tmp : tmp + 1;\n");
		sb.append("        Map<String, Object> json = new HashMap<String, Object>();\n");

		sb.append("        json.put(\"datas\", lists);// 数据\n");
		sb.append("        json.put(\"pages\", pages);// 总页\n");
		sb.append("        json.put(\"start\", start);// 页码\n");
		sb.append("        json.put(\"count\", count);// 总数\n");
		sb.append("        return json;\n");
		sb.append("    }\n\n");
		
		sb.append("    // list post jqgrid \n");
		sb.append("    @RequestMapping(value = \"getAll\", method = RequestMethod.POST)\n");
		sb.append("    @ResponseBody\n");

		sb.append(
				"    public Map<String, Object> getAll(@RequestParam(value = \"u\", required = false) String skey,\n");
		sb.append("            @RequestParam(value = \"rows\", required = false, defaultValue = \"10\") int rows,\n");
		sb.append(
				"            @RequestParam(value = \"sidx\", required = false, defaultValue = \"ts\") String sidx,\n");
		sb.append(
				"            @RequestParam(value = \"sord\", required = false, defaultValue = \"DESC\") String sord,\n\n");
		sb.append("        @RequestParam(value = \"page\", required = false, defaultValue = \"1\") int page) {\n");

		sb.append("        Map<String, Object> params = new HashMap<String, Object>();\n");
		sb.append("        params.put(\"sortFiled\", sidx);\n");
		sb.append("        params.put(\"direction\", sord);\n");
		sb.append("        params.put(\"start\", (page - 1) * rows);\n");
		sb.append("        params.put(\"perpage\", rows);\n");
		sb.append("        // 其他参数\n");
		sb.append("        if (isNotEmpty(skey)) {\n");
		sb.append("            params.put(\"skey\", skey);\n");
		sb.append("        }\n\n");

		sb.append("        //  返回参数\n");
		sb.append("        List<" + beanName + "> datas = " + beanName.toLowerCase() + "Service.queryAll(params);\n");
		sb.append("        Long count = " + beanName.toLowerCase() + "Service.queryCount(params);\n");
		sb.append("        Long tmp = count / rows;\n");
		sb.append("        Long pages = count % rows == 0 ? tmp : tmp + 1;\n");
		sb.append("        Map<String, Object> json = new HashMap<String, Object>();\n");

		sb.append("        json.put(\"rows\", datas);// 数据\n");
		sb.append("        json.put(\"total\", pages);// 总页\n");
		sb.append("        json.put(\"page\", page);// 页码\n");
		sb.append("        json.put(\"records\", count);// 总数\n");
		sb.append("        return json;\n");
		sb.append("    }\n\n");
		// list end

		// add
		sb.append("    // add get\n");
		sb.append("    @RequestMapping(value = \"add\", method = RequestMethod.GET)\n");
		sb.append("    public String add(Model model) {\n");
		sb.append("        model.addAttribute(\"action\", addAction);\n");
		sb.append("        model.addAttribute(\"title\", addTitle);\n");

		sb.append("        " + beanName + " m = new " + beanName + "();\n");
		sb.append("        m.setId(Atools.getOneKeyS());\n");
		sb.append("        model.addAttribute(\"m\", m);\n");
		sb.append("        return edit;\n");
		sb.append("    }\n\n");

		sb.append("    // add post\n");
		sb.append("    @RequestMapping(value = \"add\", method = RequestMethod.POST)\n");
		sb.append("    public String add(" + beanName + " m,Model model) {\n");
		sb.append("        model.addAttribute(\"action\", addAction);\n");
		sb.append("        model.addAttribute(\"title\", addTitle);\n");
		sb.append("        model.addAttribute(\"m\", m);\n");

		sb.append("        // 验证\n\n");
		sb.append("        //end \n");
		sb.append("        " + beanName.toLowerCase() + "Service.addBean(m);\n");
		sb.append("        return reList;\n");
		sb.append("    }\n\n");
		// add end

		// upt
		sb.append("    // upt get\n");
		sb.append("    @RequestMapping(value = \"upt/{id}\", method = RequestMethod.GET)\n");
		sb.append("    public String upt(@PathVariable(\"id\") String id,Model model) {\n");
		sb.append("        model.addAttribute(\"action\", uptAction);\n");
		sb.append("        model.addAttribute(\"title\", uptTitle);\n");

		sb.append("        " + beanName + " m = " + beanName.toLowerCase() + "Service.queryBean(id);\n");
		sb.append("        model.addAttribute(\"m\", m);\n");
		sb.append("        return edit;\n");
		sb.append("    }\n\n");

		sb.append("    // upt post\n");
		sb.append("    @RequestMapping(value = \"upt\", method = RequestMethod.POST)\n");
		sb.append("    public String upt(" + beanName + " m,Model model) {\n");
		sb.append("        model.addAttribute(\"action\", uptAction);\n");
		sb.append("        model.addAttribute(\"title\", uptTitle);\n");
		sb.append("        model.addAttribute(\"m\", m);\n");

		sb.append("        // 验证\n\n");
		sb.append("        //end \n");
		sb.append("        " + beanName.toLowerCase() + "Service.updateBean(m);\n");
		sb.append("        return reList;\n");
		sb.append("    }\n\n");
		// upt end

		// del
		sb.append("    // del\n");
		sb.append("    @RequestMapping(value = \"del/{id}\", method = RequestMethod.GET)\n");
		sb.append("    public String del(@PathVariable(\"id\") String id) {\n");
		sb.append("        " + beanName.toLowerCase() + "Service.deleteBean(id);\n");
		sb.append("        return reList;\n");
		sb.append("    }\n\n");
		// del end

		// ok
		sb.append("}\n");
		writeS(new String(sb), "utf-8", javaFilePath + File.separator + "Master" + beanName + "Controller.java");
	}

	// 6,创建html文件的DIV-Form表单文件
	public void toFormDiv() {
		String str = "";
		int i = 0;
		for (String s : fileds) {
			if (null != s) {
				str = str + "<div class=\"form-group \" id=\"" + s + "Div\">\n";
				str = str + "    <label for=\"" + s + "\" class=\"control-label col-lg-2\">" + texts.get(i)
						+ "</label>\n";
				str = str + "    <div class=\"col-lg-6\">\n";
				str = str + "        <input class=\" form-control\" id=\"" + s + "\" name=\"" + s + "\"  value=\"${m."
						+ s + "}\"  type=\"text\" required />\n";
				str = str + "    </div>\n</div>\n";
				i++;
			}
		}
		str += "\n\n\n";
		writeS(str, "utf-8", baseDir + javaMakeCodeDir + File.separator + "div" + beanName + ".html");
	}

	// 7,创建master的list.jsp
	public void makeListJSPold() {
		//
		String res = "";
		res += "<%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"UTF-8\"%>\n";
		res += "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\"%>\n";
		res += "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/fmt\" prefix=\"fmt\"%>\n";
		res += "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\"%>\n";
		res += "<%@ taglib uri=\"http://shiro.apache.org/tags\" prefix=\"shiro\"%>\n";
		res += "<%@ taglib uri=\"http://www.dizena.com/api/dxyfun\" prefix=\"dxy\"%>\n";
		res += "\n";
		res += "<!DOCTYPE html>\n";
		res += "<html lang=\"cn\">\n";
		res += "<head>\n";
		res += "\n";
		res += "<!-- style start-->\n";
		res += "<jsp:include page=\"../commStyle.jsp\" />\n";
		res += "<!-- style end-->\n";
		res += "\n";
		res += "</head>\n";
		res += "\n";
		res += "<body>\n";
		res += "\n";
		res += "	<section id=\"container\" class=\"\">\n";
		res += "\n";
		res += "\n";
		res += "		<!--main content start-->\n";
		res += "		<section id=\"main-content\">\n";
		res += "			<section class=\"wrapper\">\n";
		res += "				<!-- page start-->\n";
		res += "\n";
		res += "				<div class=\"row\">\n";
		res += "\n";
		res += "					<div class=\"col-lg-12\">\n";
		res += "						<div class=\"panel\">\n";
		res += "							<div class=\"panel-body\">\n";
		res += "\n";
		res += "								<div class=\"form-inline\">\n";
		res += "									\n";
		res += "									<div class=\"form-group\">\n";
		res += "										<label class=\"sr-only\" for=\"name\">名称</label> \n";
		res += "										<input class=\"form-control\" id=\"name\" name=\"name\" placeholder=\"名称\">\n";
		res += "									</div>\n";
		res += "									\n";
		res += "									<div class=\"form-group\">\n";
		res += "										<button onclick=\"loadTab(1)\" class=\"btn btn-danger \" type=\"button\"><i class=\"fa fa-search\">&nbsp;搜索</i></button>\n";
		res += "										\n";
		res += "										<a class=\"btn btn-primary\" href=\"${apth}/${addAction}\">增加&nbsp;<i class=\"fa fa-plus\"></i></a>\n";
		res += "									</div>\n";
		res += "								</div>\n";
		res += "\n";
		res += "  							</div>\n";
		res += "						</div>\n";
		res += "					</div>\n";
		res += "\n";
		res += "					<div class=\"col-lg-12 \">\n";
		res += "						<section class=\"panel panel-success table-responsive\">\n";
		res += "							<header class=\"panel-heading\">\n";
		res += "                             	${listHead}\n";
		res += "                          	</header>\n";
		res += "							<table class=\"table table-striped table-advance table-hover\">\n";
		res += "								<thead>\n";
		res += "									<tr id=\"tabHead\">\n";
		res += "										\n";
		res += "									</tr>\n";
		res += "								</thead>\n";
		res += "								<tbody id=\"datasTabDiv\">\n";
		res += "\n";
		res += "								</tbody>\n";
		res += "							</table>\n";
		res += "							<div class=\"alert-info text-center\">\n";
		res += "                                <ul class=\"pagination\" id=\"splitPages\">\n";
		res += "                                  	  \n";
		res += "                                </ul>\n";
		res += "                             </div>\n";
		res += "						</section>\n";
		res += "						\n";
		res += "					</div>\n";
		res += "				</div>\n";
		res += "				<!-- page end-->\n";
		res += "			</section>\n";
		res += "		</section>\n";
		res += "		<!--main content end-->\n";
		res += "\n";
		res += "\n";
		res += "		<!--footer start-->\n";
		res += "		<jsp:include page=\"../commFooter.jsp\" />\n";
		res += "		<!--footer end-->\n";
		res += "	</section>\n";
		res += "\n";
		res += "	<!-- js placed at the end of the document so the pages load faster -->\n";
		res += "	<!--script start-->\n";
		res += "	<jsp:include page=\"../commScript.jsp\" />\n";
		res += "	<script src=\"${path}/static/aatjs/myfun.js\"></script>\n";
		res += "	<!--script end-->\n";
		res += "	<script type=\"text/javascript\">\n";
		res += "		\n";
		res += "		//\n";
		res += "		\n";
		res += "		//\n";
		res += "		function del(id){\n";
		res += "			if(confirm(\"确认删除吗?\")){\n";
		res += "				window.location.href=\"${path}/${delAction}/\"+id;\n";
		res += "			}\n";
		res += "		}\n";
		res += "		\n";
		res += "		//表头\n";
		//
		int i = 0;
		String tbh = "", tds = "";
		for (String s : fileds) {
			if (null != s) {
				String title = texts.get(i);
				tbh += "'" + title + "',";
				tds += "						html+='<td>'+d." + s + "+'</td>';\n";
				i++;
			}
		}
		res += "		var TBH=['序号'," + tbh + "'操作'];\n";
		// res+=" var TBH=['序号','操作'];\n";
		res += "		function setTBHead(){\n";
		res += "			var html='';\n";
		res += "			$.each(TBH,function(i,d){\n";
		res += "				html+='<th>'+TBH[i]+'</th>';\n";
		res += "			});\n";
		res += "			$(\"#tabHead\").html(html);\n";
		res += "		}\n";
		res += "		//end\n";
		res += "		\n";
		res += "		//加载函数\n";
		res += "		function loadTab(s){\n\n";
		res += "			//正在加载\n";
		res += "			var htmlLoad='<tr>';\n";
		res += "			htmlLoad+='<td colspan=\"'+TBH.length+'\" align=\"center\">';\n";
		res += "			htmlLoad+='<img src=\"/static/master/img/load.gif\" />';\n";
		res += "			htmlLoad+='</td>';\n";
		res += "			htmlLoad+='</tr>';\n";
		res += "			$('#datasTabDiv').html(htmlLoad);\n";
		res += "			\n";
		res += "			var url=\"${list}\";\n";
		res += "			var ps={\"s\":s};\n";
		res += "				ps.u=$(\"#name\").val();\n";
		res += "				\n";
		res += "			$.post(url,ps,function(json){\n";
		res += "				if(json.count>0){\n";
		res += "					//有数据\n";
		res += "					var html=\"\";\n";
		res += "					$.each(json.datas,function(i,d){\n";
		res += "						html+='<tr>';\n";
		res += "						html+='<td>'+(i+1)+'</td>';\n";
		res += "						//\n";
		res += tds;
		res += "						//html+='<td><a href=\"${path}/cctvzc/news/'+(d.id)+'.html\" target=\"_blank\">'+(d.activityTitle)+'</a></td>';\n";
		res += "						//html+='<td>'+d.meetingTitle+'</td>';\n";
		res += "						//html+='<td>'+num2DateYMD(d.meetingTime)+'</td>';\n";
		res += "						\n";
		res += "						//\n";
		res += "						html+='<td>';\n";
		res += "						html+='<a href=\"${path}/${uptAction}/'+(d.id)+'\" class=\"btn btn-primary  btn-xs\"><i class=\"fa fa-pencil\"></i>&nbsp;编辑</a>&nbsp;';\n";
		res += "						html+='<button onclick=\"del(\\''+(d.id)+'\\')\" type=\"button\" class=\"btn btn-danger  btn-xs\"><i class=\"fa fa-trash \"></i>&nbsp;删除</button>&nbsp;';\n";
		res += "						html+='</td>';\n";
		res += "						html+='</tr>';\n";
		res += "					});\n";
		res += "					$(\"#datasTabDiv\").html(html);\n";
		res += "				}else{\n";
		res += "					//没有数据\n";
		res += "					var html='<tr>';\n";
		res += "					html+='<td colspan=\"'+TBH.length+'\" align=\"center\">';\n";
		res += "					html+='<b style=\"color:red;\">没有数据</b>';\n";
		res += "					html+='</td>';\n";
		res += "					html+='</tr>';\n";
		res += "					$(\"#datasTabDiv\").html(html);\n";
		res += "				}\n";
		res += "				splitPages(json.pages,json.start);\n";
		res += "			});\n";
		res += "		}\n";
		res += "		\n";
		res += "		$(function(){\n";
		res += "			setTBHead();//加载表头\n";
		res += "			loadTab(1);\n";
		res += "		});\n";
		res += "	</script>\n";
		res += "\n";
		res += "</body>\n";
		res += "</html>\n";

		//
		String file = baseDir + javaMakeCodeDir + File.separator + "master" + File.separator + beanName.toLowerCase()
				+ File.separator + "listOld.jsp";
		writeS(res, "utf-8", file);
	}

	// 7.2,创建master的list.jsp
	public void makeListJSP() {
		//
		String res = "";
		res += "<%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"UTF-8\"%>\n";
		res += "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\"%>\n";
		res += "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/fmt\" prefix=\"fmt\"%>\n";
		res += "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\"%>\n";
		res += "<%@ taglib uri=\"http://shiro.apache.org/tags\" prefix=\"shiro\"%>\n";
		res += "<%@ taglib uri=\"http://www.dizena.com/api/dxyfun\" prefix=\"dxy\"%>\n";
		res += "\n";
		res += "<!DOCTYPE html>\n";
		res += "<html lang=\"cn\">\n";
		res += "<head>\n";
		res += "\n";
		res += "<!-- style start-->\n";
		res += "<jsp:include page=\"../jqgridCss.jsp\" />\n";
		res += "<!-- style end-->\n";
		res += "\n";
		res += "</head>\n";
		res += "\n";
		res += "<body>\n";
		res += "\n";
		res += "	<section id=\"container\" class=\"\">\n";
		res += "\n";
		res += "\n";
		res += "		<!--main content start-->\n";
		res += "		<section id=\"main-content\">\n";
		res += "			<section class=\"wrapper\">\n";
		res += "				<!-- page start-->\n";
		res += "\n";
		res += "				<div class=\"row\">\n";
		res += "\n";
		res += "					<div class=\"col-lg-12\">\n";
		res += "						<div class=\"panel\">\n";
		res += "							<div class=\"panel-body\">\n";
		res += "\n";
		res += "								<div class=\"form-inline\">\n";
		res += "									\n";
		res += "									<div class=\"form-group\">\n";
		res += "										<label class=\"sr-only\" for=\"name\">搜索关键词</label> \n";
		res += "										<input class=\"form-control\" id=\"name\" name=\"name\" placeholder=\"搜索关键词\">\n";
		res += "									</div>\n";
		res += "									\n";
		res += "									<div class=\"form-group\">\n";
		res += "										<button id=\"searchBtn\" class=\"btn btn-danger \" type=\"button\"><i class=\"fa fa-search\">&nbsp;搜索</i></button>\n";
		res += "										\n";
		res += "										<a class=\"btn btn-primary\" href=\"${apth}/${addAction}\">增加&nbsp;<i class=\"fa fa-plus\"></i></a>\n";
		res += "									</div>\n";
		res += "								</div>\n";
		res += "\n";
		res += "  							</div>\n";
		res += "						</div>\n";
		res += "					</div>\n";
		res += "\n";
		res += "					<div class=\"col-lg-12 \">\n";
		res += "						<section class=\"panel panel-success table-responsive\">\n";
		res += "							<header class=\"panel-heading\">\n";
		res += "                             	${listHead}\n";
		res += "                          	</header>\n";
		res += "							<table id=\"tabdiv\" class=\"table table-striped table-advance table-hover\">\n";
		res += "							</table>\n";
		res += "							<div id=\"tabdiv_page\" class=\"alert-info text-center\">\n";
		res += "                            </div>\n";
		res += "						</section>\n";
		res += "						\n";
		res += "					</div>\n";
		res += "				</div>\n";
		res += "				<!-- page end-->\n";
		res += "			</section>\n";
		res += "		</section>\n";
		res += "		<!--main content end-->\n";
		res += "\n";
		res += "\n";
		res += "		<!--footer start-->\n";
		res += "		<jsp:include page=\"../commFooter.jsp\" />\n";
		res += "		<!--footer end-->\n";
		res += "	</section>\n";
		res += "\n";
		res += "	<!-- js placed at the end of the document so the pages load faster -->\n";
		res += "	<!--script start-->\n";
		res += "	<jsp:include page=\"../jqgridScript.jsp\" />\n";
		res += "	<!--script end-->\n";
		res += "	<script type=\"text/javascript\">\n";
		res += "		$(function(){\n";
		res += "		    initLoad();\n";
		res += "		    $(\"#searchBtn\").click(function(){\n";
		res += "		        var datas={\"u\":$(\"#name\").val(),\"sortorder\":\"DESC\"};\n";
		res += "		        loadTab(\"tabdiv\",datas);\n";
		res += "			});\n";
		res += "		});\n\n";
		
		res += "		function initLoad(){\n";
		res += "		    var datas={\"u\":$(\"#name\").val(),\"sortorder\":\"DESC\"};\n";
		//
		int i = 0;
		String col = "",model="";
		for (String s : fileds) {
			if (null != s && s.length() > 0 ) {
				String title = texts.get(i);
				col += "'" + title + "',";
				model +="{name:'"+s+"',index:'"+s+"',formatter:function(cv, op, rb){return cv;}},\n\t\t\t\t";
				i++;
			}
		}
		model += "{\n\t\t\t\t";
		model += "    name:'id',index:'id',formatter:function(cv, op, rb){\n\t\t\t\t";
		model += "        var html = '';\n\t\t\t\t";
		model += "        html+='<a href=\"${path}/${uptAction}/'+cv+'\" class=\"btn btn-primary  btn-xs\"><i class=\"fa fa-pencil\"></i>&nbsp;编辑</a>&nbsp;';\n\t\t\t\t";
		model += "        html+='<button onclick=\"del(\\''+cv+'\\')\" type=\"button\" class=\"btn btn-danger  btn-xs\"><i class=\"fa fa-trash \"></i>&nbsp;删除</button>&nbsp;';\n\t\t\t\t";
		model += "        return html;\n\t\t\t\t";
		model += "    }\n\t\t\t\t";
		model += "}\n\t\t\t\t";
		res += "{\n\t\t\t    ";
		
		res += "		    var cols=[" + col + "'操作'];\n";
		res += "		    var models=[\n                "+model+"];\n";
		res += "			//加载和搜索\n";
		res += "			loadData(\"/master/" + beanName.toLowerCase() + "/getAll\",\"tabdiv\",datas,cols,models);\n";
		res += "		}\n\n";
		res += "	</script>\n";
		res += "\n";
		res += "</body>\n";
		res += "</html>\n";

		//
		String file = baseDir + javaMakeCodeDir + File.separator + "master" + File.separator + beanName.toLowerCase()
				+ File.separator + "list.jsp";
		writeS(res, "utf-8", file);
	}

	
	// 8,创建master的edit.jsp
	public void makeEditJSP() {
		String str = "",res="";
		//
		res+="<%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"UTF-8\"%>\n";
		res+="<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\"%>\n";
		res+="<%@ taglib uri=\"http://java.sun.com/jsp/jstl/fmt\" prefix=\"fmt\"%>\n";
		res+="<%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\"%>\n";
		res+="<%@ taglib uri=\"http://shiro.apache.org/tags\" prefix=\"shiro\"%>\n";
		res+="<%@ taglib uri=\"http://www.dizena.com/api/dxyfun\" prefix=\"dxy\"%>\n";
		res+="\n";
		res+="<!DOCTYPE html>\n";
		res+="<html lang=\"cn\">\n";
		res+="<head>\n";
		res+="\n";
		res+="<!-- style start-->\n";
		res+="<jsp:include page=\"../commStyle.jsp\" />\n";
		res+="<link href=\"${path}/static/master/css/bootstrap-datetimepicker.min.css\" rel=\"stylesheet\" type=\"text/css\">\n";
		res+="<!-- style end-->\n";
		res+="\n";
		res+="</head>\n";
		res+="\n";
		res+="<body>\n";
		res+="\n";
		res+="	<section id=\"container\" class=\"\">\n";
		res+="\n";
		res+="\n";
		res+="		<!--main content start-->\n";
		res+="		<section id=\"main-content\">\n";
		res+="			<section class=\"wrapper\">\n";
		res+="				<!-- page start-->\n";
		res+="				<div class=\"row\">\n";
		res+="					<div class=\"col-lg-12\">\n";
		res+="						<section class=\"panel\">\n";
		res+="							<header class=\"panel-heading\">${title}</header>\n";
		res+="							<div class=\"panel-body\">\n";
		res+="								<div style=\"color: red;text-align: center;height: 30px;line-height: 30px;\">\n";
		res+="									${error}\n";
		res+="								</div>\n";
		res+="								<div class=\" form\">\n";
		res+="									<form class=\"cmxform form-horizontal tasi-form\" id=\"commentForm\" method=\"post\" action=\"${path}/${action}\">\n";
		res+="										<input type=\"hidden\" name=\"id\" value=\"${m.id}\">\n";
		res+="										\n";
		res+="										\n\n";
		//begin
		//
		int i = 0;
		for (String s : fileds) {
			if (null != s) {
				str = str + "										<div class=\"form-group \" id=\"" + s + "Div\">\n";
				str = str + "										    <label for=\"" + s + "\" class=\"control-label col-lg-2\">" + texts.get(i)+ "</label>\n";
				str = str + "										    <div class=\"col-lg-6\">\n";
				str = str + "										        <input class=\" form-control\" id=\"" + s + "\" name=\"" + s + "\"  value=\"${m."+ s + "}\"  type=\"text\" required />\n";
				str = str + "										    </div>\n";
				str = str + "										</div>\n\n";
				i++;
			}
		}
		str += "\n\n\n";
		res+=str;
		//end
		res+="										\n";
		res+="										\n";
		res+="										<!-- 经典特例 -->\n";
		res+="										<div class=\"form-group \">\n";
		res+="										    <label for=\"pic\" class=\"control-label col-lg-2\">图片</label>\n";
		res+="										    <div class=\"col-lg-6\">\n";
		res+="										        <input class=\" form-control\" id=\"pic\" name=\"pic\"  value=\"${m.pic}\"  type=\"text\"  />\n";
		res+="										    </div>\n";
		res+="										    <div class=\"col-lg-2\">\n";
		res+="										    	<button id=\"uppic\" class=\"btn btn-default\" type=\"button\">上传</button>\n";
		res+="										    </div>\n";
		res+="										    \n";
		res+="										</div>\n";
		res+="										\n";
		res+="										<div class=\"form-group \">\n";
		res+="										    <label for=\"meetingTime\" class=\"control-label col-lg-2\">会议时间</label>\n";
		res+="										    <div class=\"col-lg-6\">\n";
		res+="										        <input class=\"dateymd form-control\" id=\"meetingTime\" name=\"meetingTime\"  value=\"<fmt:formatDate value=\"${m.meetingTime}\" pattern=\"yyyy-MM-dd\"/>\"  type=\"text\"  />\n";
		res+="										    </div>\n";
		res+="										</div>\n";
		res+="										\n";
		res+="										<div class=\"form-group \">\n";
		res+="										    <label for=\"type\" class=\"control-label col-lg-2\">类型</label>\n";
		res+="										    <div class=\"col-lg-6\">\n";
		res+="										    	<select class=\" form-control\" id=\"type\" name=\"type\">\n";
		res+="										    		<option value=\"1\" <c:if test=\"${m.type=='1'}\">selected=\"selected\"</c:if>  >培训课件</option>\n";
		res+="										    	</select>\n";
		res+="										    </div>\n";
		res+="										</div>\n";
		res+="										\n";
		res+="										<div class=\"form-group \">\n";
		res+="										    <label for=\"meetingIntroduce\" class=\"control-label col-lg-2\">会议介绍</label>\n";
		res+="										    <div class=\"col-lg-8\">\n";
		res+="										    	<textarea class=\" form-control\" id=\"meetingIntroduce\" name=\"meetingIntroduce\">${m.meetingIntroduce}</textarea>\n";
		res+="										    </div>\n";
		res+="										</div>\n";
		res+="										\n";
		res+="										\n";
		res+="										<div class=\"form-group\">\n";
		res+="											<div class=\"col-lg-offset-2 col-lg-10\">\n";
		res+="												<button class=\"btn btn-danger\" type=\"submit\">提交</button>\n";
		res+="												<button class=\"btn btn-info\" type=\"reset\" onclick=\"window.history.back();\" >返回</button>\n";
		res+="											</div>\n";
		res+="										</div> \n";
		res+="									</form>\n";
		res+="								</div>\n";
		res+="\n";
		res+="							</div>\n";
		res+="						</section>\n";
		res+="					</div>\n";
		res+="				</div>\n";
		res+="				<!-- page end-->\n";
		res+="			</section>\n";
		res+="		</section>\n";
		res+="		<!--main content end-->\n";
		res+="\n";
		res+="\n";
		res+="		<!--footer start-->\n";
		res+="		<jsp:include page=\"../commFooter.jsp\" />\n";
		res+="		<!--footer end-->\n";
		res+="	</section>\n";
		res+="\n";
		res+="	<!-- js placed at the end of the document so the pages load faster -->\n";
		res+="	<!--script start-->\n";
		res+="	<jsp:include page=\"../commScript.jsp\" />\n";
		res+="	<!--script end-->\n";
		res+="	\n";
		res+="	<script charset=\"utf-8\" src=\"${path}/static/keditor/kindeditor-min.js\"></script>\n";
		res+="	<script charset=\"utf-8\" src=\"${path}/static/keditor/zh_CN.js\"></script>\n";
		res+="	<link href=\"${path}/static/keditor/themes/default/default.css\" rel=\"stylesheet\" />\n";
		res+="	<script type=\"text/javascript\" src=\"${path}/static/master/js/bootstrap-datetimepicker.min.js\"></script>\n";
		res+="	<script type=\"text/javascript\" src=\"${path}/static/master/js/bootstrap-datetimepicker.zh-CN.js\"></script>\n";
		res+="	\n";
		res+="	<script type=\"text/javascript\">\n";
		res+="		KindEditor.ready(function(K) {\n";
		res+="			var editor = K.editor({\n";
		res+="				uploadJson : \"${path}/assist/upload_json.do\",\n";
		res+="				fileManagerJson : \"${path}/assist/file_manager_json.do\",\n";
		res+="				allowFileManager : true,\n";
		res+="				allowImageUpload : true\n";
		res+="			});\n";
		res+="			\n";
		res+="			//\n";
		res+="			K('#uppic').click(function() {\n";
		res+="				editor.loadPlugin('image', function() {\n";
		res+="					editor.plugin.imageDialog({\n";
		res+="						imageUrl : K('#pic').val(),\n";
		res+="						clickFn : function(url, title, width, height, border, align) {\n";
		res+="							K('#pic').val(url);\n";
		res+="							editor.hideDialog();\n";
		res+="						}\n";
		res+="					});\n";
		res+="				});\n";
		res+="			});\n";
		res+="			//\n";
		res+="			K.create('textarea[id=\"meetingIntroduce\"]', {\n";
		res+="				uploadJson : \"${path}/upload/upload_json.do\",\n";
		res+="				fileManagerJson : \"${path}/upload/file_manager_json.do\",\n";
		res+="				allowFileManager : true\n";
		res+="			});\n";
		res+="			//\n";
		res+="			\n";
		res+="		});\n";
		res+="		\n";
		res+="		\n";
		res+="		$(function(){\n";
		res+="			//\n";
		res+="			$('.dateymd').datetimepicker({\n";
		res+="				language : 'zh-CN',\n";
		res+="				format : 'yyyy-mm-dd',\n";
		res+="				todayBtn : true,\n";
		res+="				autoclose : true,\n";
		res+="				todayHighlight : true,\n";
		res+="				startView : 2,\n";
		res+="				minView : 2,\n";
		res+="				maxView : 4,\n";
		res+="				forceParse : true\n";
		res+="			});\n";
		res+="			//\n";
		res+="		});\n";
		res+="	</script>\n";
		res+="\n";
		res+="</body>\n";
		res+="</html>\n";
		//end
		String file=baseDir + javaMakeCodeDir + File.separator + "master"
				+ File.separator + beanName.toLowerCase() + File.separator + "edit.jsp";
		writeS(res, "utf-8", file);
	}

	// 100：取得XLSM 表格的值
	private static String getXlssVal(XSSFCell c) {
		try {
			if (c.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) {
				return String.valueOf(c.getBooleanCellValue());
			} else if (c.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
				return String.valueOf(c.getNumericCellValue());
			} else {
				return String.valueOf(c.getStringCellValue());
			}
		} catch (Exception e) {
			return "";
		}
	}

	// 101：根据字段类型，得到java的属性类型；
	private String getFiledType(String str) {
		if (str.toLowerCase().contains("char")) {
			return "String";
		}
		if (str.toLowerCase().startsWith("int")) {
			return "Integer";
		}
		if (str.toLowerCase().contains("bigint")) {
			return "Long";
		}
		if (str.toLowerCase().contains("float") || str.toLowerCase().contains("double")|| str.toLowerCase().contains("dec")) {
			return "Double";
		}
		
		if (str.toLowerCase().contains("number") && str.toLowerCase().contains(",")) {
			return "Double";
		}
		
		if (str.toLowerCase().contains("number") && !str.toLowerCase().contains(",")) {
			return "Integer";
		}
		
		if (str.toLowerCase().contains("date")) {
			return "Date";
		}
		if (str.toLowerCase().contains("bit")) {
			return "Boolean";
		}
		return "String";
	}

	// 102：创建文件包
	private void createPackage(String pathname) {
		File f = new File(pathname);
		if (!f.exists()) {
			f.mkdirs();
		}
	}

	// 103：判断不为空
	private boolean isNotEmpty(String str) {
		if (null == str) {
			return false;
		}
		if ("".equals(str) || str.length() == 0) {
			return false;
		}
		return true;

	}

	// 104：写出文件
	private void writeS(String str, String encoding, String sfile) {
		char[] cuf = str.toCharArray();// 将指定的字串序列化为byte[]
		try {
			int lastIndex = sfile.lastIndexOf(File.separator);
			String sfileDir=sfile.substring(0,lastIndex);
			File file = new File(sfileDir);
			if (!file.exists()) {
				file.mkdirs();
			}
			OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(sfile), encoding);
			out.write(cuf);
			out.flush();
			out.close();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	//

}
